package com.dinnerwithfriends.client.dinner.invite;

import com.dinnerwithfriends.client.GWTEntryPoint;
import com.dinnerwithfriends.client.emails.SendEmail;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * 
 * @Feature
 */
public class DinnerConfirmation extends VerticalPanel {

	public static HTML buttonLogout = new HTML();

	public DinnerConfirmation() {

		String message = "Restaurant: <b>"
				+ CreateDinner.textBoxRestaurant.getValue() + "</b><br><br>"
				+ "Dates & Times: <b>" + CreateDinner.dateBox1.getValue()
				+ "  OR " + CreateDinner.dateBox2.getValue() + "</b><br><br>"
				+ "Friends: <b>" + CreateDinner.selectedFriends.toString()
				+ "</b><br><br>" + "Extra Message: <b>"
				+ CreateDinner.textAreaMessage.getValue() + "</b><br><br>"
				+ "Pre-paid: <b>" + CreateDinner.chckbxPrepaid.getValue()
				+ "</b><br><br>" + "Option: <b>" + getPostOptions() + "</b>";

		new SendEmail(GWTEntryPoint.facebookUser.getFacebookName() + "<br><br>"
				+ message);

		HTML lblDinnerWith = new HTML(
				"<font size=5 color='gray'>::: DINNER WITH FRIENDS :::</font>");
		this.add(lblDinnerWith);
		lblDinnerWith.setSize("385px", "66px");

		HTML lblThisEventIs = new HTML("Thanks <b>"
				+ GWTEntryPoint.facebookUser.getFacebookName()
				+ "</b> for using Dinner With Friends!");
		this.add(lblThisEventIs);

		HTML userLabel = new HTML("Your dinner was spread!");
		this.add(userLabel);
		userLabel.setSize("469px", "36px");

		HTML hprlnkRestaurant = new HTML(message);
		this.add(hprlnkRestaurant);

		this.add(buttonLogout);

	}

	private String getPostOptions() {

		String options = "<br>";

		if (CreateDinner.chckbxSendEmails.getValue()) {
			options += CreateDinner.chckbxSendEmails.getText() + "<br>";
		}

		if (CreateDinner.chckbxTweet.getValue()) {
			options += CreateDinner.chckbxTweet.getText() + "<br>";
		}

		if (CreateDinner.chckbxSendFacebookMessages.getValue()) {
			options += CreateDinner.chckbxSendFacebookMessages.getText()
					+ "<br>";
		}

		if (CreateDinner.chckbxPostOnMy.getValue()) {
			options += CreateDinner.chckbxPostOnMy.getText() + "<br>";
		}

		if (CreateDinner.chckbxPostOnFriends.getValue()) {
			options += CreateDinner.chckbxPostOnFriends.getText() + "<br>";
		}

		return options;
	}
}
